<?php #include("./include/inc_asegurar.php"); ?>

	<div id="masthead">
		
		<div class="content_pad">
			
			<h1 class="no_breadcrumbs">Art&iacute;culos</h1>
			<!-- 
			<div id="search">
				<form action="/search" method="get">
					<input type="text" value="" placeholder="Search" name="search" id="search_input" title="Search" />					
					<input type="submit" value="" name="submit" class="submit" />					
				</form>
			</div> #search -->
			
		</div> <!-- .content_pad -->
		
	</div> <!-- #masthead -->	
	
	<div id="content" class="xgrid">
			
		<div class="x12">
			
			<h2>Listado de art&iacute;culos</h2>
			
			<?php if( f_validar_permiso($_SESSION["perf_codigo"], 31, 1, $conn)) { ?>
			<p>
				<a class="btn-icon btn-grey btn-plus" href="?articulo_edit&a=agregar"><span></span>Agregar art&iacute;culo</a>
			</p>
			<?php } ?>
			
			<table class="data display datatable">
				<thead>
					<tr>
						<th><span title="C&oacute;digo">Cod.</a></th> 
						<th><span title="Descripci&oacute;n">Descripci&oacute;n</a></th> 
						<th><span title="Abreviatura">Abreviatura</a></th> 
						<th><span title="Proveedor">Proveedor</a></th> 
						<th><span title="Tipo artículo">Tipo artículo</a></th>
						<th><span title="Acci&oacute;n">Acci&oacute;n</a></th>
					</tr>
				</thead>
				<tbody>
				<?php
				/* 

DROP TABLE IF EXISTS `articulos`;
CREATE TABLE IF NOT EXISTS `articulos` (
  `art_codigo` int(11) NOT NULL AUTO_INCREMENT,
  `art_descripcion` text,
  `art_abrev` text,
  `art_precio_compra` int(11) DEFAULT NULL,
  `art_precio_venta` int(11) DEFAULT NULL,
  `art_codigo_barra` varchar(1000) DEFAULT NULL,
  `art_c_proveedores` int(11) NOT NULL DEFAULT '1',
  `art_t_articulos` int(11) NOT NULL DEFAULT '1',
  `art_e_articulos` int(11) NOT NULL DEFAULT '1',
  `art_r_fecha_creacion` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `art_r_fecha_modificacion` datetime DEFAULT NULL,
  `art_r_usuario` varchar(25) NOT NULL,
  PRIMARY KEY (`art_codigo`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;


DROP TABLE IF EXISTS `t_articulo`;
CREATE TABLE IF NOT EXISTS `t_articulo` (
  `tar_tipo` int(11) NOT NULL AUTO_INCREMENT,
  `tar_descripcion` varchar(25) DEFAULT NULL,
  `tar_r_fecha_creacion` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `tar_r_fecha_modificacion` datetime DEFAULT NULL,
  `tar_r_usuario` varchar(25) NOT NULL,
  PRIMARY KEY (`tar_tipo`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;

 */
					$Q_select  = " SELECT ";
					$Q_select .= " art_codigo,  ";
					$Q_select .= " art_descripcion,  ";
					$Q_select .= " art_abrev,  ";
					$Q_select .= " prov_razon_social,  ";
					$Q_select .= " tar_descripcion  ";
					$Q_select .= " from articulos ";
					$Q_select .= " inner join proveedores ";
					$Q_select .= " on prov_codigo = art_c_proveedores ";
					$Q_select .= " inner join t_articulo ";
					$Q_select .= " on art_t_articulos = tar_tipo ";
					$Q_select .= " where art_e_articulos = 1 ";

					$Res_Q_select = mysql_query( $Q_select,$conn );
					
					while ( $Reg_Q_select = mysql_fetch_array( $Res_Q_select ) ){
						
						$ii_c_articulo	= $Reg_Q_select["art_codigo"];
						$is_descripcion = $Reg_Q_select["art_descripcion"];
						$is_abrev		= $Reg_Q_select["art_abrev"];
						$is_razon_social = $Reg_Q_select["prov_razon_social"];
						$is_t_articulo	= $Reg_Q_select["tar_descripcion"];

					?>
					<tr>
						<td><?php echo $ii_c_articulo; ?></td> 
						<td><?php echo $is_descripcion; ?></td>
						<td><?php echo $is_abrev; ?></td>
						<td><?php echo $is_razon_social; ?></td>
						<td><?php echo $is_t_articulo; ?></td>
						<td>
						<?php if( f_validar_permiso($_SESSION["perf_codigo"], 31, 3, $conn)) { ?>
							<a href="?articulo_edit&a=editar&ii_c_articulo=<?php echo $ii_c_articulo; ?>">[Editar]</a>
						<?php } ?>
						<?php if( f_validar_permiso($_SESSION["perf_codigo"], 31, 4, $conn)){ ?>
							<a href="?articulo_edit&a=eliminar&ii_c_articulo=<?php echo $ii_c_articulo; ?>">[Eliminar]</a>
						<?php } ?>
						<?php if( f_validar_permiso($_SESSION["perf_codigo"], 32, 2, $conn)){ ?>
							<a href="?nota_articulo&ii_c_articulo=<?php echo $ii_c_articulo; ?>">[Notas]</a>
						<?php } ?>
						<?php /* if( f_validar_permiso($_SESSION["perf_codigo"], 23, 2, $conn)){ ?>
							<a href="?cta_cte_proveedor&ii_c_articulo=<?php echo $ii_c_articulo; ?>">[Cta Cte]</a>
						<?php } */ ?>
						</td>
					</tr>
					<?php } ?>					
				</tbody>
			</table>
			 
		</div>  
		
	</div> <!-- #content -->